home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_emacs.idb / usr / freeware / info / emacs-18.z / emacs-18
Encoding:
GNU Info File  |  1998-10-28  |  43.8 KB  |  1,072 lines

  1. This is Info file ../info/emacs, produced by Makeinfo-1.63 from the
  2. input file emacs.texi.
  3.  
  4. 
  5. File: emacs,  Node: Special Diary Entries,  Prev: Adding to Diary,  Up: Diary
  6.  
  7. Special Diary Entries
  8. ---------------------
  9.  
  10.    In addition to entries based on calendar dates, the diary file can
  11. contain "sexp entries" for regular events such as anniversaries.  These
  12. entries are based on Lisp expressions (sexps) that Emacs evaluates as
  13. it scans the diary file.  Instead of a date, a sexp entry contains `%%'
  14. followed by a Lisp expression which must begin and end with
  15. parentheses.  The Lisp expression determines which dates the entry
  16. applies to.
  17.  
  18.    Calendar mode provides commands to insert certain commonly used sexp
  19. entries:
  20.  
  21. `i a'
  22.      Add an anniversary diary entry for the selected date
  23.      (`insert-anniversary-diary-entry').
  24.  
  25. `i b'
  26.      Add a block diary entry for the current region
  27.      (`insert-block-diary-entry').
  28.  
  29. `i c'
  30.      Add a cyclic diary entry starting at the date
  31.      (`insert-cyclic-diary-entry').
  32.  
  33.    If you want to make a diary entry that applies to the anniversary of
  34. a specific date, move point to that date and use the `i a' command.
  35. This displays the end of your diary file in another window and inserts
  36. the anniversary description; you can then type the rest of the diary
  37. entry.  The entry looks like this:
  38.  
  39.      %%(diary-anniversary 10 31 1948) Arthur's birthday
  40.  
  41. This entry applies to October 31 in any year after 1948; `10 31 1948'
  42. specifies the date.  (If you are using the European calendar style, the
  43. month and day are interchanged.)  The reason this expression requires a
  44. beginning year is that advanced diary functions can use it to calculate
  45. the number of elapsed years.
  46.  
  47.    A "block" diary entry applies to a specified range of consecutive
  48. dates.  Here is a block diary entry that applies to all dates from June
  49. 24, 1990 through July 10, 1990:
  50.  
  51.      %%(diary-block 6 24 1990 7 10 1990) Vacation
  52.  
  53. The `6 24 1990' indicates the starting date and the `7 10 1990'
  54. indicates the stopping date.  (Again, if you are using the European
  55. calendar style, the month and day are interchanged.)
  56.  
  57.    To insert a block entry, place point and the mark on the two dates
  58. that begin and end the range, and type `i b'.  This command displays
  59. the end of your diary file in another window and inserts the block
  60. description; you can then type the diary entry.
  61.  
  62.    "Cyclic" diary entries repeat after a fixed interval of days.  To
  63. create one, select the starting date and use the `i c' command.  The
  64. command prompts for the length of interval, then inserts the entry,
  65. which looks like this:
  66.  
  67.      %%(diary-cyclic 50 3 1 1990) Renew medication
  68.  
  69. This entry applies to March 1, 1990 and every 50th day following; `3 1
  70. 1990' specifies the starting date.  (If you are using the European
  71. calendar style, the month and day are interchanged.)
  72.  
  73.    All three of these commands make marking diary entries.  To insert a
  74. nonmarking entry, give a numeric argument to the command.  For example,
  75. `C-u i a' makes a nonmarking anniversary diary entry.
  76.  
  77.    Marking sexp diary entries in the calendar is *extremely*
  78. time-consuming, since every date visible in the calendar window must be
  79. individually checked.  So it's a good idea to make sexp diary entries
  80. nonmarking (with `&') when possible.
  81.  
  82.    Another sophisticated kind of sexp entry, a "floating" diary entry,
  83. specifies a regularly-occurring event by offsets specified in days,
  84. weeks, and months.  It is comparable to a crontab entry interpreted by
  85. the `cron' utility.  Here is a nonmarking, floating diary entry that
  86. applies to the last Thursday in November:
  87.  
  88.      &%%(diary-float 11 4 -1) American Thanksgiving
  89.  
  90. The 11 specifies November (the eleventh month), the 4 specifies Thursday
  91. (the fourth day of the week, where Sunday is numbered zero), and the -1
  92. specifies "last" (1 would mean "first", 2 would mean "second", -2 would
  93. mean "second-to-last", and so on).  The month can be a single month or
  94. a list of months.  Thus you could change the 11 above to `'(1 2 3)' and
  95. have the entry apply to the last Thursday of January, February, and
  96. March.  If the month is `t', the entry applies to all months of the
  97. year.
  98.  
  99.    Most generally, sexp diary entries can perform arbitrary
  100. computations to determine when they apply.  *Note Sexp Diary Entries:
  101. (elisp)Sexp Diary Entries.
  102.  
  103. 
  104. File: emacs,  Node: Appointments,  Next: Daylight Savings,  Prev: Diary,  Up: Calendar/Diary
  105.  
  106. Appointments
  107. ============
  108.  
  109.    If you have a diary entry for an appointment, and that diary entry
  110. begins with a recognizable time of day, Emacs can warn you, several
  111. minutes beforehand, that that appointment is pending.  Emacs alerts you
  112. to the appointment by displaying a message in the mode line.
  113.  
  114.    To enable appointment notification, you must enable the time display
  115. feature of Emacs, `M-x display-time' (*note Mode Line::.).  You must
  116. also add the function `appt-make-list' to the `diary-hook', like this:
  117.  
  118.      (add-hook 'diary-hook 'appt-make-list)
  119.  
  120.    With these preparations done, when you display the diary (either with
  121. the `d' command in the calendar window or with the `M-x diary'
  122. command), it sets up an appointment list of all the diary entries found
  123. with recognizable times of day, and reminds you just before each of
  124. them.
  125.  
  126.    For example, suppose the diary file contains these lines:
  127.  
  128.      Monday
  129.        9:30am Coffee break
  130.       12:00pm Lunch
  131.  
  132. Then on Mondays, after you have displayed the diary, you will be
  133. reminded at 9:20am about your coffee break and at 11:50am about lunch.
  134.  
  135.    You can write times in am/pm style (with `12:00am' standing for
  136. midnight and `12:00pm' standing for noon), or 24-hour European/military
  137. style.  You need not be consistent; your diary file can have a mixture
  138. of the two styles.
  139.  
  140.    Emacs updates the appointments list automatically just after
  141. midnight.  This also displays the next day's diary entries in the diary
  142. buffer, unless you set `appt-display-diary' to `nil'.
  143.  
  144.    You can also use the appointment notification facility like an alarm
  145. clock.  The command `M-x appt-add' adds entries to the appointment list
  146. without affecting your diary file.  You delete entries from the
  147. appointment list with `M-x appt-delete'.
  148.  
  149.    You can turn off the appointment notification feature at any time by
  150. setting `appt-issue-message' to `nil'.
  151.  
  152. 
  153. File: emacs,  Node: Daylight Savings,  Prev: Appointments,  Up: Calendar/Diary
  154.  
  155. Daylight Savings Time
  156. =====================
  157.  
  158.    Emacs understands the difference between standard time and daylight
  159. savings time--the times given for sunrise, sunset, solstices,
  160. equinoxes, and the phases of the moon take that into account.  The rules
  161. for daylight savings time vary from place to place and have also varied
  162. historically from year to year.  To do the job properly, Emacs needs to
  163. know which rules to use.
  164.  
  165.    Some operating systems keep track of the rules that apply to the
  166. place where you are; on these systems, Emacs gets the information it
  167. needs from the system automatically.  If some or all of this
  168. information is missing, Emacs fills in the gaps with the rules
  169. currently used in Cambridge, Massachusetts.  If the resulting rules are
  170. not what you want, you can tell Emacs the rules to use by setting
  171. certain variables.
  172.  
  173.    These values should be Lisp expressions that refer to the variable
  174. `year', and evaluate to the Gregorian date on which daylight savings
  175. time starts or (respectively) ends, in the form of a list `(MONTH DAY
  176. YEAR)'.  The values should be `nil' if your area does not use daylight
  177. savings time.
  178.  
  179.    Emacs uses these expressions to determine the starting date of
  180. daylight savings time for the holiday list and for correcting times of
  181. day in the solar and lunar calculations.
  182.  
  183.    The values for Cambridge, Massachusetts are as follows:
  184.  
  185.      (calendar-nth-named-day 1 0 4 year)
  186.      (calendar-nth-named-day -1 0 10 year)
  187.  
  188. That is, the first 0th day (Sunday) of the fourth month (April) in the
  189. year specified by `year', and the last Sunday of the tenth month
  190. (October) of that year.  If daylight savings time were changed to start
  191. on October 1, you would set `calendar-daylight-savings-starts' to this:
  192.  
  193.      (list 10 1 year)
  194.  
  195.    If there is no daylight savings time at your location, or if you want
  196. all times in standard time, set `calendar-daylight-savings-starts' and
  197. `calendar-daylight-savings-ends' to `nil'.
  198.  
  199.    The variable `calendar-daylight-time-offset' specifies the
  200. difference between daylight savings time and standard time, measured in
  201. minutes.  The value for Cambridge, Massachusetts is 60.
  202.  
  203.    The two variables `calendar-daylight-savings-starts-time' and
  204. `calendar-daylight-savings-ends-time' specify the number of minutes
  205. after midnight local time when the transition to and from daylight
  206. savings time should occur.  For Cambridge, Massachusetts both variables'
  207. values are 120.
  208.  
  209. 
  210. File: emacs,  Node: Gnus,  Next: Shell,  Prev: Calendar/Diary,  Up: Top
  211.  
  212. Gnus
  213. ====
  214.  
  215.    Gnus is an Emacs package primarily designed for reading and posting
  216. Usenet news.  It can also be used to read and respond to messages from a
  217. number of other sources--mail, remote directories, digests, and so on.
  218.  
  219.    Here we introduce Gnus and describe several basic features.  For
  220. full details, see *Note Gnus: (gnus)Top.
  221.  
  222.    To start Gnus, type `M-x gnus RET'.
  223.  
  224. * Menu:
  225.  
  226. * Buffers of Gnus::       The group, summary and article buffers.
  227. * Gnus Startup::       What you should know about starting Gnus.
  228. * Summary of Gnus::       A short description of the basic Gnus commands.
  229.  
  230. 
  231. File: emacs,  Node: Buffers of Gnus,  Next: Gnus Startup,  Up: Gnus
  232.  
  233. Gnus Buffers
  234. ------------
  235.  
  236.    As opposed to most normal Emacs packages, Gnus uses a number of
  237. different buffers to display information and to receive commands.  The
  238. three buffers users spend most of their time in are the "group buffer",
  239. the "summary buffer" and the "article buffer".
  240.  
  241.    The "group buffer" contains a list of groups.  This is the first
  242. buffer Gnus displays when it starts up.  It normally displays only the
  243. groups to which you subscribe and that contain unread articles.  Use
  244. this buffer to select a specific group.
  245.  
  246.    The "summary buffer" lists one line for each article in a single
  247. group.  By default, the author, the subject and the line number are
  248. displayed for each article, but this is customizable, like most aspects
  249. of Gnus display.  The summary buffer is created when you select a group
  250. in the group buffer, and is killed when you exit the group.  Use this
  251. buffer to select an article.
  252.  
  253.    The "article buffer" displays the article.  In normal Gnus usage,
  254. you don't select this buffer--all useful article-oriented commands work
  255. in the summary buffer.  But you can select the article buffer, and
  256. execute all Gnus commands from that buffer, if you want to.
  257.  
  258. 
  259. File: emacs,  Node: Gnus Startup,  Next: Summary of Gnus,  Prev: Buffers of Gnus,  Up: Gnus
  260.  
  261. When Gnus Starts Up
  262. -------------------
  263.  
  264.    At startup, Gnus reads your `.newsrc' news initialization file and
  265. attempts to communicate with the local news server, which is a
  266. repository of news articles.  The news server need not be the same
  267. computer you are logged in on.
  268.  
  269.    If you start Gnus and connect to the server, but do not see any
  270. newsgroups listed in the group buffer, type `L' or `A k' to get a
  271. listing of all the groups.  Then type `u' to toggle subscription to
  272. groups.
  273.  
  274.    The first time you start Gnus, Gnus subscribes you to a few selected
  275. groups.  All other groups start out as "killed groups" for you; you can
  276. list them with `A k'.  All new groups that subsequently come to exist
  277. at the news server become "zombie groups" for you; type `A z' to list
  278. them.  You can subscribe to a group shown in these lists using the `u'
  279. command.
  280.  
  281.    When you quit Gnus with `q', it automatically records in your
  282. `.newsrc' and `.newsrc.eld' initialization files the subscribed or
  283. unsubscribed status of all groups.  You should normally not edit these
  284. files manually, but you may if you know how.
  285.  
  286. 
  287. File: emacs,  Node: Summary of Gnus,  Prev: Gnus Startup,  Up: Gnus
  288.  
  289. Summary of Gnus Commands
  290. ------------------------
  291.  
  292.    Reading news is a two step process:
  293.  
  294.   1. Choose a group in the group buffer.
  295.  
  296.   2. Select articles from the summary buffer.  Each article selected is
  297.      displayed in the article buffer in a large window, below the
  298.      summary buffer in its small window.
  299.  
  300.    Each Gnus buffer has its own special commands; however, the meanings
  301. of any given key in the various Gnus buffers are usually analogous, even
  302. if not identical.  Here are commands for the group and summary buffers:
  303.  
  304. `q'
  305.      In the group buffer, update your `.newsrc' initialization file and
  306.      quit Gnus.
  307.  
  308.      In the summary buffer, exit the current group and return to the
  309.      group buffer.  Thus, typing `q' twice quits Gnus.
  310.  
  311. `L'
  312.      In the group buffer, list all the groups available on your news
  313.      server (except those you have killed).  This may be a long list!
  314.  
  315. `l'
  316.      In the group buffer, list only the groups to which you subscribe
  317.      and which contain unread articles.
  318.  
  319. `u'
  320.      In the group buffer, unsubscribe from (or subscribe to) the group
  321.      listed in the line that point is on.  When you quit Gnus by typing
  322.      `q', Gnus lists in your `.newsrc' file which groups you have
  323.      subscribed to.  The next time you start Gnus, you won't see this
  324.      group, because Gnus normally displays only subscribed-to groups.
  325.  
  326. `C-k'
  327.      In the group buffer, "kill" the current line's group--don't even
  328.      list it in `.newsrc' from now on.  This affects future Gnus
  329.      sessions as well as the present session.
  330.  
  331.      When you quit Gnus by typing `q', Gnus writes information in the
  332.      file `.newsrc' describing all newsgroups except those you have
  333.      "killed."
  334.  
  335. `SPC'
  336.      In the group buffer, select the group on the line under the cursor
  337.      and display the first unread article in that group.
  338.  
  339.      In the summary buffer,
  340.  
  341.         * Select the article on the line under the cursor if none is
  342.           selected.
  343.  
  344.         * Scroll the text of the selected article (if there is one).
  345.  
  346.         * Select the next unread article if at the end of the current
  347.           article.
  348.  
  349.      Thus, you can move through all the articles by repeatedly typing
  350.      SPC.
  351.  
  352. `DEL'
  353.      In the group buffer, move point to the previous group containing
  354.      unread articles.
  355.  
  356.      In the summary buffer, scroll the text of the article backwards.
  357.  
  358. `n'
  359.      Move point to the next unread group, or select the next unread
  360.      article.
  361.  
  362. `p'
  363.      Move point to the previous unread group, or select the previous
  364.      unread article.
  365.  
  366. `C-n'
  367. `C-p'
  368.      Move point to the next or previous item, even if it is marked as
  369.      read.  This does not select the article or group on that line.
  370.  
  371. `s'
  372.      In the summary buffer, do an incremental search of the current
  373.      text in the article buffer, just as if you switched to the article
  374.      buffer and typed `C-s'.
  375.  
  376. `M-s REGEXP RET'
  377.      In the summary buffer, search forward for articles containing a
  378.      match for REGEXP.
  379.  
  380. 
  381. File: emacs,  Node: Shell,  Next: Emacs Server,  Prev: Gnus,  Up: Top
  382.  
  383. Running Shell Commands from Emacs
  384. =================================
  385.  
  386.    Emacs has commands for passing single command lines to inferior shell
  387. processes; it can also run a shell interactively with input and output
  388. to an Emacs buffer named `*shell*'.
  389.  
  390. `M-! CMD RET'
  391.      Run the shell command line CMD and display the output
  392.      (`shell-command').
  393.  
  394. `M-| CMD RET'
  395.      Run the shell command line CMD with region contents as input;
  396.      optionally replace the region with the output
  397.      (`shell-command-on-region').
  398.  
  399. `M-x shell'
  400.      Run a subshell with input and output through an Emacs buffer.  You
  401.      can then give commands interactively.
  402.  
  403. * Menu:
  404.  
  405. * Single Shell::           How to run one shell command and return.
  406. * Interactive Shell::      Permanent shell taking input via Emacs.
  407. * Shell Mode::             Special Emacs commands used with permanent shell.
  408. * History: Shell History.  Repeating previous commands in a shell buffer.
  409. * Options: Shell Options.  Options for customizing Shell mode.
  410. * Remote Host::            Connecting to another computer.
  411.  
  412. 
  413. File: emacs,  Node: Single Shell,  Next: Interactive Shell,  Up: Shell
  414.  
  415. Single Shell Commands
  416. ---------------------
  417.  
  418.    `M-!' (`shell-command') reads a line of text using the minibuffer
  419. and executes it as a shell command in a subshell made just for that
  420. command.  Standard input for the command comes from the null device.
  421. If the shell command produces any output, the output goes into an Emacs
  422. buffer named `*Shell Command Output*', which is displayed in another
  423. window but not selected.  A numeric argument, as in `M-1 M-!', directs
  424. this command to insert any output into the current buffer.  In that
  425. case, point is left before the output and the mark is set after the
  426. output.
  427.  
  428.    If the shell command line ends in `&', it runs asynchronously.
  429.  
  430.    `M-|' (`shell-command-on-region') is like `M-!' but passes the
  431. contents of the region as the standard input to the shell command,
  432. instead of no input.  If a numeric argument is used, meaning insert the
  433. output in the current buffer, then the old region is deleted first and
  434. the output replaces it as the contents of the region.
  435.  
  436.    Both `M-!' and `M-|' use `shell-file-name' to specify the shell to
  437. use.  This variable is initialized based on your `SHELL' environment
  438. variable when Emacs is started.  If the file name does not specify a
  439. directory, the directories in the list `exec-path' are searched; this
  440. list is initialized based on the environment variable `PATH' when Emacs
  441. is started.  Your `.emacs' file can override either or both of these
  442. default initializations.
  443.  
  444.    Both `M-!' and `M-|' wait for the shell command to complete.  To
  445. stop waiting, type `C-g' to quit; that terminates the shell command
  446. with the signal `SIGINT'--the same signal that `C-c' normally generates
  447. in the shell.  Emacs waits until the command actually terminates.  If
  448. the shell command doesn't stop (because it ignores the `SIGINT'
  449. signal), type `C-g' again; this sends the command a `SIGKILL' signal
  450. which is impossible to ignore.
  451.  
  452. 
  453. File: emacs,  Node: Interactive Shell,  Next: Shell Mode,  Prev: Single Shell,  Up: Shell
  454.  
  455. Interactive Inferior Shell
  456. --------------------------
  457.  
  458.    To run a subshell interactively, putting its typescript in an Emacs
  459. buffer, use `M-x shell'.  This creates (or reuses) a buffer named
  460. `*shell*' and runs a subshell with input coming from and output going
  461. to that buffer.  That is to say, any "terminal output" from the subshell
  462. goes into the buffer, advancing point, and any "terminal input" for the
  463. subshell comes from text in the buffer.  To give input to the subshell,
  464. go to the end of the buffer and type the input, terminated by RET.
  465.  
  466.    Emacs does not wait for the subshell to do anything.  You can switch
  467. windows or buffers and edit them while the shell is waiting, or while
  468. it is running a command.  Output from the subshell waits until Emacs
  469. has time to process it; this happens whenever Emacs is waiting for
  470. keyboard input or for time to elapse.
  471.  
  472.    To make multiple subshells, rename the buffer `*shell*' to something
  473. different using `M-x rename-uniquely'.  Then type `M-x shell' again to
  474. create a new buffer `*shell*' with its own subshell.  If you rename
  475. this buffer as well, you can create a third one, and so on.  All the
  476. subshells run independently and in parallel.
  477.  
  478.    The file name used to load the subshell is the value of the variable
  479. `explicit-shell-file-name', if that is non-`nil'.  Otherwise, the
  480. environment variable `ESHELL' is used, or the environment variable
  481. `SHELL' if there is no `ESHELL'.  If the file name specified is
  482. relative, the directories in the list `exec-path' are searched; this
  483. list is initialized based on the environment variable `PATH' when Emacs
  484. is started.  Your `.emacs' file can override either or both of these
  485. default initializations.
  486.  
  487.    As soon as the subshell is started, it is sent as input the contents
  488. of the file `~/.emacs_SHELLNAME', if that file exists, where SHELLNAME
  489. is the name of the file that the shell was loaded from.  For example,
  490. if you use bash, the file sent to it is `~/.emacs_bash'.
  491.  
  492.    `cd', `pushd' and `popd' commands given to the inferior shell are
  493. watched by Emacs so it can keep the `*shell*' buffer's default
  494. directory the same as the shell's working directory.  These commands
  495. are recognized syntactically by examining lines of input that are sent.
  496. If you use aliases for these commands, you can tell Emacs to recognize
  497. them also.  For example, if the value of the variable
  498. `shell-pushd-regexp' matches the beginning of a shell command line,
  499. that line is regarded as a `pushd' command.  Change this variable when
  500. you add aliases for `pushd'.  Likewise, `shell-popd-regexp' and
  501. `shell-cd-regexp' are used to recognize commands with the meaning of
  502. `popd' and `cd'.  These commands are recognized only at the beginning
  503. of a shell command line.
  504.  
  505.    If Emacs gets an error while trying to handle what it believes is a
  506. `cd', `pushd' or `popd' command, it runs the hook
  507. `shell-set-directory-error-hook' (*note Hooks::.).
  508.  
  509.    If Emacs does not properly track changes in the current directory of
  510. the subshell, use the command `M-x dirs' to ask the shell what its
  511. current directory is.  This command works for shells that support the
  512. most common command syntax; it may not work for unusual shells.
  513.  
  514. 
  515. File: emacs,  Node: Shell Mode,  Next: Shell History,  Prev: Interactive Shell,  Up: Shell
  516.  
  517. Shell Mode
  518. ----------
  519.  
  520.    Shell buffers use Shell mode, which defines several special keys
  521. attached to the `C-c' prefix.  They are chosen to resemble the usual
  522. editing and job control characters present in shells that are not under
  523. Emacs, except that you must type `C-c' first.  Here is a complete list
  524. of the special key bindings of Shell mode:
  525.  
  526. `RET'
  527.      At end of buffer send line as input; otherwise, copy current line
  528.      to end of buffer and send it (`comint-send-input').  When a line is
  529.      copied, any text at the beginning of the line that matches the
  530.      variable `shell-prompt-pattern' is left out; this variable's value
  531.      should be a regexp string that matches the prompts that your shell
  532.      uses.
  533.  
  534. `TAB'
  535.      Complete the command name or file name before point in the shell
  536.      buffer (`comint-dynamic-complete').  TAB also completes history
  537.      references (*note History References::.) and environment variable
  538.      names.
  539.  
  540.      The variable `shell-completion-fignore' specifies a list of file
  541.      name extensions to ignore in Shell mode completion.  The default
  542.      setting ignores file names ending in `~', `#' or `%'.  Other
  543.      related Comint modes use the variable `comint-completion-fignore'
  544.      instead.
  545.  
  546. `M-?'
  547.      Display temporarily a list of the possible completions of the file
  548.      name before point in the shell buffer
  549.      (`comint-dynamic-list-filename-completions').
  550.  
  551. `C-d'
  552.      Either delete a character or send EOF
  553.      (`comint-delchar-or-maybe-eof').  Typed at the end of the shell
  554.      buffer, `C-d' sends EOF to the subshell.  Typed at any other
  555.      position in the buffer, `C-d' deletes a character as usual.
  556.  
  557. `C-c C-a'
  558.      Move to the beginning of the line, but after the prompt if any
  559.      (`comint-bol').
  560.  
  561. `C-c C-u'
  562.      Kill all text pending at end of buffer to be sent as input
  563.      (`comint-kill-input').
  564.  
  565. `C-c C-w'
  566.      Kill a word before point (`backward-kill-word').
  567.  
  568. `C-c C-c'
  569.      Interrupt the shell or its current subjob if any
  570.      (`comint-interrupt-subjob').
  571.  
  572. `C-c C-z'
  573.      Stop the shell or its current subjob if any (`comint-stop-subjob').
  574.  
  575. `C-c C-\'
  576.      Send quit signal to the shell or its current subjob if any
  577.      (`comint-quit-subjob').
  578.  
  579. `C-c C-o'
  580.      Kill the last batch of output from a shell command
  581.      (`comint-kill-output').  This is useful if a shell command spews
  582.      out lots of output that just gets in the way.
  583.  
  584. `C-c C-r'
  585. `C-M-l'
  586.      Scroll to display the beginning of the last batch of output at the
  587.      top of the window; also move the cursor there
  588.      (`comint-show-output').
  589.  
  590. `C-c C-e'
  591.      Scroll to put the end of the buffer at the bottom of the window
  592.      (`comint-show-maximum-output').
  593.  
  594. `C-c C-f'
  595.      Move forward across one shell command, but not beyond the current
  596.      line (`shell-forward-command').  The variable
  597.      `shell-command-regexp' specifies how to recognize the end of a
  598.      command.
  599.  
  600. `C-c C-b'
  601.      Move backward across one shell command, but not beyond the current
  602.      line (`shell-backward-command').
  603.  
  604. `C-c C-l'
  605.      Display the buffer's history of shell commands in another window
  606.      (`comint-dynamic-list-input-ring').
  607.  
  608. `M-x dirs'
  609.      Ask the shell what its current directory is, so that Emacs can
  610.      agree with the shell.
  611.  
  612. `M-x send-invisible RET TEXT RET'
  613.      Send TEXT as input to the shell, after reading it without echoing.
  614.      This is useful when a shell command runs a program that asks for
  615.      a password.
  616.  
  617.      Alternatively, you can arrange for Emacs to notice password prompts
  618.      and turn off echoing for them, as follows:
  619.  
  620.           (add-hook 'comint-output-filter-functions
  621.                     'comint-watch-for-password-prompt)
  622.  
  623. `M-x comint-continue-subjob'
  624.      Continue the shell process.  This is useful if you accidentally
  625.      suspend the shell process.(1)
  626.  
  627. `M-x comint-strip-ctrl-m'
  628.      Discard all control-m characters from the current group of shell
  629.      output.  The most convenient way to use this command is to make it
  630.      run automatically when you get output from the subshell.  To do
  631.      that, evaluate this Lisp expression:
  632.  
  633.           (add-hook 'comint-output-filter-functions
  634.                     'comint-strip-ctrl-m)
  635.  
  636. `M-x comint-truncate-buffer'
  637.      This command truncates the shell buffer to a certain maximum
  638.      number of lines, specified by the variable
  639.      `comint-buffer-maximum-size'.  Here's how to do this automatically
  640.      each time you get output from the subshell:
  641.  
  642.           (add-hook 'comint-output-filter-functions
  643.                     'comint-truncate-buffer)
  644.  
  645.    Shell mode also customizes the paragraph commands so that only shell
  646. prompts start new paragraphs.  Thus, a paragraph consists of an input
  647. command plus the output that follows it in the buffer.
  648.  
  649.    Shell mode is a derivative of Comint mode, a general purpose mode for
  650. communicating with interactive subprocesses.  Most of the features of
  651. Shell mode actually come from Comint mode, as you can see from the
  652. command names listed above.  The special features of Shell mode in
  653. particular include the choice of regular expression for detecting
  654. prompts, the directory tracking feature, and a few user commands.
  655.  
  656.    Other Emacs features that use variants of Comint mode include GUD
  657. (*note Debuggers::.) and `M-x run-lisp' (*note External Lisp::.).
  658.  
  659.    You can use `M-x comint-run' to execute any program of your choice
  660. in a subprocess using unmodified Comint mode--without the
  661. specializations of Shell mode.
  662.  
  663.    ---------- Footnotes ----------
  664.  
  665.    (1)  You should not suspend the shell process.  Suspending a subjob
  666. of the shell is a completely different matter--that is normal practice,
  667. but you must use the shell to continue the subjob; this command won't
  668. do it.
  669.  
  670. 
  671. File: emacs,  Node: Shell History,  Next: Shell Options,  Prev: Shell Mode,  Up: Shell
  672.  
  673. Shell Command History
  674. ---------------------
  675.  
  676.    Shell buffers support three ways of repeating earlier commands.  You
  677. can use the same keys used in the minibuffer; these work much as they do
  678. in the minibuffer, inserting text from prior commands while point
  679. remains always at the end of the buffer.  You can move through the
  680. buffer to previous inputs in their original place, then resubmit them or
  681. copy them to the end.  Or you can use a `!'-style history reference.
  682.  
  683. * Menu:
  684.  
  685. * Ring: Shell Ring.             Fetching commands from the history list.
  686. * Copy: Shell History Copying.  Moving to a command and then copying it.
  687. * History References::          Expanding `!'-style history references.
  688.  
  689. 
  690. File: emacs,  Node: Shell Ring,  Next: Shell History Copying,  Up: Shell History
  691.  
  692. Shell History Ring
  693. ..................
  694.  
  695. `M-p'
  696.      Fetch the next earlier old shell command.
  697.  
  698. `M-n'
  699.      Fetch the next later old shell command.
  700.  
  701. `M-r REGEXP RET'
  702. `M-s REGEXP RET'
  703.      Search backwards or forwards for old shell commands that match
  704.      REGEXP.
  705.  
  706.    Shell buffers provide a history of previously entered shell
  707. commands.  To reuse shell commands from the history, use the editing
  708. commands `M-p', `M-n', `M-r' and `M-s'.  These work just like the
  709. minibuffer history commands except that they operate on the text at the
  710. end of the shell buffer, where you would normally insert text to send
  711. to the shell.
  712.  
  713.    `M-p' fetches an earlier shell command to the end of the shell
  714. buffer.  Successive use of `M-p' fetches successively earlier shell
  715. commands, each replacing any text that was already present as potential
  716. shell input.  `M-n' does likewise except that it finds successively
  717. more recent shell commands from the buffer.
  718.  
  719.    The history search commands `M-r' and `M-s' read a regular
  720. expression and search through the history for a matching command.  Aside
  721. from the choice of which command to fetch, they work just like `M-p'
  722. and `M-r'.  If you enter an empty regexp, these commands reuse the same
  723. regexp used last time.
  724.  
  725.    When you find the previous input you want, you can resubmit it by
  726. typing RET, or you can edit it first and then resubmit it if you wish.
  727.  
  728.    These commands get the text of previous shell commands from a special
  729. history list, not from the shell buffer itself.  Thus, editing the shell
  730. buffer, or even killing large parts of it, does not affect the history
  731. that these commands access.
  732.  
  733.    Some shells store their command histories in files so that you can
  734. refer to previous commands from previous shell sessions.  Emacs reads
  735. the command history file for your chosen shell, to initialize its own
  736. command history.  The file name is `~/.bash_history' for bash,
  737. `~/.sh_history' for ksh, and `~/.history' for other shells.
  738.  
  739. 
  740. File: emacs,  Node: Shell History Copying,  Next: History References,  Prev: Shell Ring,  Up: Shell History
  741.  
  742. Shell History Copying
  743. .....................
  744.  
  745. `C-c C-p'
  746.      Move point to the previous prompt (`comint-previous-prompt').
  747.  
  748. `C-c C-n'
  749.      Move point to the following prompt (`comint-next-prompt').
  750.  
  751. `C-c RET'
  752.      Copy the input command which point is in, inserting the copy at
  753.      the end of the buffer (`comint-copy-old-input').  This is useful
  754.      if you move point back to a previous command.  After you copy the
  755.      command, you can submit the copy as input with RET.  If you wish,
  756.      you can edit the copy before resubmitting it.
  757.  
  758.    Moving to a previous input and then copying it with `C-c RET'
  759. produces the same results--the same buffer contents--that you would get
  760. by using `M-p' enough times to fetch that previous input from the
  761. history list.  However, `C-c RET' copies the text from the buffer,
  762. which can be different from what is in the history list if you edit the
  763. input text in the buffer after it has been sent.
  764.  
  765. 
  766. File: emacs,  Node: History References,  Prev: Shell History Copying,  Up: Shell History
  767.  
  768. Shell History References
  769. ........................
  770.  
  771.    Various shells including csh and bash support "history references"
  772. that begin with `!' and `^'.  Shell mode can understand these
  773. constructs and perform the history substitution for you.  If you insert
  774. a history reference and type TAB, this searches the input history for a
  775. matching command, performs substitution if necessary, and places the
  776. result in the buffer in place of the history reference.  For example,
  777. you can fetch the most recent command beginning with `mv' with `! m v
  778. TAB'.  You can edit the command if you wish, and then resubmit the
  779. command to the shell by typing RET.
  780.  
  781.    History references take effect only following a shell prompt.  The
  782. variable `shell-prompt-pattern' specifies how to recognize a shell
  783. prompt.  Comint modes in general use the variable
  784. `comint-prompt-regexp' to specify how to find a prompt; Shell mode uses
  785. `shell-prompt-pattern' to set up the local value of
  786. `comint-prompt-regexp'.
  787.  
  788.    Shell mode can optionally expand history references in the buffer
  789. when you send them to the shell.  To request this, set the variable
  790. `comint-input-autoexpand' to `input'.
  791.  
  792.    You can make SPC perform history expansion by binding SPC to the
  793. command `comint-magic-space'.
  794.  
  795. 
  796. File: emacs,  Node: Shell Options,  Next: Remote Host,  Prev: Shell History,  Up: Shell
  797.  
  798. Shell Mode Options
  799. ------------------
  800.  
  801.    If the variable `comint-scroll-to-bottom-on-input' is non-`nil',
  802. insertion and yank commands scroll the selected window to the bottom
  803. before inserting.
  804.  
  805.    If `comint-scroll-show-maximum-output' is non-`nil', then scrolling
  806. due to arrival of output tries to place the last line of text at the
  807. bottom line of the window, so as to show as much useful text as
  808. possible.  (This mimics the scrolling behavior of many terminals.) The
  809. default is `nil'.
  810.  
  811.    By setting `comint-scroll-to-bottom-on-output', you can opt for
  812. having point jump to the end of the buffer whenever output arrives--no
  813. matter where in the buffer point was before.  If the value is `this',
  814. point jumps in the selected window.  If the value is `all', point jumps
  815. in each window that shows the comint buffer.  If the value is `other',
  816. point jumps in all nonselected windows that show the current buffer.
  817. The default value is `nil', which means point does not jump to the end.
  818.  
  819.    The variable `comint-input-ignoredups' controls whether successive
  820. identical inputs are stored in the input history.  A non-`nil' value
  821. means to omit an input that is the same as the previous input.  The
  822. default is `nil', which means to store each input even if it is equal
  823. to the previous input.
  824.  
  825.    Three variables customize file name completion.  The variable
  826. `comint-completion-addsuffix' controls whether completion inserts a
  827. space or a slash to indicate a fully completed file or directory name
  828. (non-`nil' means do insert a space or slash).
  829. `comint-completion-recexact', if non-`nil', directs TAB to choose the
  830. shortest possible completion if the usual Emacs completion algorithm
  831. cannot add even a single character.  `comint-completion-autolist', if
  832. non-`nil', says to list all the possible completions whenever
  833. completion is not exact.
  834.  
  835.    The command `comint-dynamic-complete-variable' does variable name
  836. completion using the environment variables as set within Emacs.  The
  837. variables controlling file name completion apply to variable name
  838. completion too.  This command is normally available through the menu
  839. bar.
  840.  
  841.    Command completion normally considers only executable files.  If you
  842. set `shell-command-execonly' to `nil', it considers nonexecutable files
  843. as well.
  844.  
  845.    You can configure the behavior of `pushd'.  Variables control
  846. whether `pushd' behaves like `cd' if no argument is given
  847. (`shell-pushd-tohome'), pop rather than rotate with a numeric argument
  848. (`shell-pushd-dextract'), and only add directories to the directory
  849. stack if they are not already on it (`shell-pushd-dunique').  The
  850. values you choose should match the underlying shell, of course.
  851.  
  852. 
  853. File: emacs,  Node: Remote Host,  Prev: Shell Options,  Up: Shell
  854.  
  855. Remote Host Shell
  856. -----------------
  857.  
  858.    Emacs provides two commands for logging in to another computer and
  859. communicating with it through an Emacs buffer.
  860.  
  861. `M-x telnet RET HOSTNAME RET'
  862.      Set up a Telnet connection to the computer named HOSTNAME.
  863.  
  864. `M-x rlogin RET HOSTNAME RET'
  865.      Set up an Rlogin connection to the computer named HOSTNAME.
  866.  
  867.    Use `M-x telnet' to set up a Telnet connection to another computer.
  868. (Telnet is the standard Internet protocol for remote login.) It reads
  869. the host name of the other computer as an argument with the minibuffer.
  870. Once the connection is established, talking to the other computer
  871. works like talking to a subshell: you can edit input with the usual
  872. Emacs commands, and send it a line at a time by typing RET.  The output
  873. is inserted in the Telnet buffer interspersed with the input.
  874.  
  875.    Use `M-x rlogin' to set up an Rlogin connection.  Rlogin is another
  876. remote login communication protocol, essentially much like the Telnet
  877. protocol but incompatible with it, and supported only by certain
  878. systems.  Rlogin's advantages are that you can arrange not to have to
  879. give your user name and password when communicating between two machines
  880. you frequently use, and that you can make an 8-bit-clean connection.
  881. (To do that in Emacs, set `rlogin-explicit-args' to `("-8")' before you
  882. run Rlogin.)
  883.  
  884.    `M-x rlogin' sets up the default file directory of the Emacs buffer
  885. to access the remote host via FTP (*note File Names::.), and it tracks
  886. the shell commands that change the current directory just like Shell
  887. mode.
  888.  
  889.    There are two ways of doing directory tracking in an Rlogin
  890. buffer--either with remote directory names `/HOST:DIR/' or with local
  891. names (that works if the "remote" machine shares file systems with your
  892. machine of origin).  You can use the command
  893. `rlogin-directory-tracking-mode' to switch modes.  No argument means
  894. use remote directory names, a positive argument means use local names,
  895. and a negative argument means turn off directory tracking.
  896.  
  897. 
  898. File: emacs,  Node: Emacs Server,  Next: Hardcopy,  Prev: Shell,  Up: Top
  899.  
  900. Using Emacs as a Server
  901. =======================
  902.  
  903.    Various programs such as `mail' can invoke your choice of editor to
  904. edit a particular piece of text, such as a message that you are
  905. sending.  By convention, most of these programs use the environment
  906. variable `EDITOR' to specify which editor to run.  If you set `EDITOR'
  907. to `emacs', they invoke Emacs--but in an inconvenient fashion, by
  908. starting a new, separate Emacs process.  This is inconvenient because
  909. it takes time and because the new Emacs process doesn't share the
  910. buffers in the existing Emacs process.
  911.  
  912.    You can arrange to use your existing Emacs process as the editor for
  913. programs like `mail' by using the Emacs client and Emacs server
  914. programs.  Here is how.
  915.  
  916.    First, the preparation.  Within Emacs, call the function
  917. `server-start'.  (Your `.emacs' file can do this automatically if you
  918. add the expression `(server-start)' to it.)  Then, outside Emacs, set
  919. the `EDITOR' environment variable to `emacsclient'.  (Note that some
  920. programs use a different environment variable; for example, to make TeX
  921. use `emacsclient', you should set the `TEXEDIT' environment variable to
  922. `emacsclient +%d %s'.)
  923.  
  924.    Then, whenever any program invokes your specified `EDITOR' program,
  925. the effect is to send a message to your principal Emacs telling it to
  926. visit a file.  (That's what the program `emacsclient' does.) Emacs
  927. displays the buffer immediately and you can immediately begin editing
  928. it.
  929.  
  930.    When you've finished editing that buffer, type `C-x #'
  931. (`server-edit').  This saves the file and sends a message back to the
  932. `emacsclient' program telling it to exit.  The programs that use
  933. `EDITOR' wait for the "editor" (actually, `emacsclient') to exit.  `C-x
  934. #' also checks for other pending external requests to edit various
  935. files, and selects the next such file.
  936.  
  937.    You can switch to a server buffer manually if you wish; you don't
  938. have to arrive at it with `C-x #'.  But `C-x #' is the only way to say
  939. that you are "finished" with one.
  940.  
  941.    If you set the variable `server-window' to a window or a frame, `C-x
  942. #' displays the server buffer in that window or in that frame.
  943.  
  944.    While `mail' or another application is waiting for `emacsclient' to
  945. finish, `emacsclient' does not read terminal input.  So the terminal
  946. that `mail' was using is effectively blocked for the duration.  In
  947. order to edit with your principal Emacs, you need to be able to use it
  948. without using that terminal.  There are two ways to do this:
  949.  
  950.    * Using a window system, run `mail' and the principal Emacs in two
  951.      separate windows.  While `mail' is waiting for `emacsclient', the
  952.      window where it was running is blocked, but you can use Emacs by
  953.      switching windows.
  954.  
  955.    * Use Shell mode in Emacs to run the other program such as `mail';
  956.      then, `emacsclient' blocks only the subshell under Emacs, and you
  957.      can still use Emacs to edit the file.
  958.  
  959.    Some programs write temporary files for you to edit.  After you edit
  960. the temporary file, the program reads it back and deletes it.  If the
  961. Emacs server is later asked to edit the same file name, it should assume
  962. this has nothing to do with the previous occasion for that file name.
  963. The server accomplishes this by killing the temporary file's buffer when
  964. you finish with the file.  Use the variable `server-temp-file-regexp'
  965. to specify which files are temporary in this sense; its value should be
  966. a regular expression that matches file names that are temporary.
  967.  
  968. 
  969. File: emacs,  Node: Hardcopy,  Next: Postscript,  Prev: Emacs Server,  Up: Top
  970.  
  971. Hardcopy Output
  972. ===============
  973.  
  974.    The Emacs commands for making hardcopy let you print either an entire
  975. buffer or just part of one, either with or without page headers.  See
  976. also the hardcopy commands of Dired (*note Misc File Ops::.) and the
  977. diary (*note Diary Commands::.).
  978.  
  979. `M-x print-buffer'
  980.      Print hardcopy of current buffer with page headings containing the
  981.      file name and page number.
  982.  
  983. `M-x lpr-buffer'
  984.      Print hardcopy of current buffer without page headings.
  985.  
  986. `M-x print-region'
  987.      Like `print-buffer' but print only the current region.
  988.  
  989. `M-x lpr-region'
  990.      Like `lpr-buffer' but print only the current region.
  991.  
  992.    The hardcopy commands (aside from the Postscript commands) pass extra
  993. switches to the `lpr' program based on the value of the variable
  994. `lpr-switches'.  Its value should be a list of strings, each string an
  995. option starting with `-'.  For example, to use a printer named
  996. `nearme', set `lpr-switches' like this:
  997.  
  998.      (setq lpr-switches '("-Pnearme"))
  999.  
  1000.    The variable `lpr-command' specifies the name of the printer program
  1001. to run; the default value depends on your operating system type.  On
  1002. most systems, the default is `"lpr"'.  The variable
  1003. `lpr-headers-switches' similarly specifies the extra switches to use to
  1004. make page headers.  The variable `lpr-add-switches' controls whether to
  1005. supply `-T' and `-J' options (suitable for `lpr') to the printer
  1006. program: `nil' means don't add them.  `lpr-add-switches' should be
  1007. `nil' if your printer program is not compatible with `lpr'.
  1008.  
  1009. 
  1010. File: emacs,  Node: Postscript,  Next: Sorting,  Prev: Hardcopy,  Up: Top
  1011.  
  1012. Postscript Hardcopy
  1013. ===================
  1014.  
  1015.    These commands convert buffer contents to Postscript, either
  1016. printing it or leaving it in another Emacs buffer.
  1017.  
  1018. `M-x ps-print-buffer'
  1019.      Print hardcopy of the current buffer in Postscript form.
  1020.  
  1021. `M-x ps-print-region'
  1022.      Print hardcopy of the current region in Postscript form.
  1023.  
  1024. `M-x ps-print-buffer-with-faces'
  1025.      Print hardcopy of the current buffer in Postscript form, showing
  1026.      the faces used in the text by means of Postscript features.
  1027.  
  1028. `M-x ps-print-region-with-faces'
  1029.      Print hardcopy of the current region in Postscript form, showing
  1030.      the faces used in the text.
  1031.  
  1032. `M-x ps-spool-buffer'
  1033.      Generate Postscript for the current buffer text.
  1034.  
  1035. `M-x ps-spool-region'
  1036.      Generate Postscript for the current region.
  1037.  
  1038. `M-x ps-spool-buffer-with-faces'
  1039.      Generate Postscript for the current buffer, showing the faces used.
  1040.  
  1041. `M-x ps-spool-region-with-faces'
  1042.      Generate Postscript for the current region, showing the faces used.
  1043.  
  1044.    The Postscript commands, `ps-print-buffer' and `ps-print-region',
  1045. print buffer contents in Postscript form.  One command prints the
  1046. entire buffer; the other, just the region.  The corresponding
  1047. `-with-faces' commands, `ps-print-buffer-with-faces' and
  1048. `ps-print-region-with-faces', use Postscript features to show the faces
  1049. (fonts and colors) in the text properties of the text being printed.
  1050.  
  1051.    If you are using a color display, you can print a buffer of program
  1052. code with color highlighting by turning on Font-Lock mode in that
  1053. buffer, and using `ps-print-buffer-with-faces'.
  1054.  
  1055.    All four of the commands above use the variables `ps-lpr-command'
  1056. and `ps-lpr-switches' to specify how to print the output.
  1057. `ps-lpr-command' specifies the command name to run, and
  1058. `ps-lpr-switches' specifies command line options to use.  If you don't
  1059. set these variables yourself, they take their initial values from
  1060. `lpr-command' and `lpr-switches'.
  1061.  
  1062.    The variable `ps-print-header' controls whether these commands add
  1063. header lines to each page--set it to `nil' to turn headers off.  You
  1064. can turn off color processing by setting `ps-print-color-p' to `nil'.
  1065. Many other customization variables for these commands are defined and
  1066. described in the Lisp file `ps-print.el'.
  1067.  
  1068.    The commands whose names have `spool' instead of `print' generate
  1069. the Postscript output in an Emacs buffer instead of sending it to the
  1070. printer.
  1071.  
  1072.